/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.site.user.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author zhanjun
 */
@Entity
@Table(name = "tb_group")
@NamedQueries({
    @NamedQuery(name = "TbGroup.findAll", query = "SELECT t FROM TbGroup t"),
    @NamedQuery(name = "TbGroup.findByIdGroup", query = "SELECT t FROM TbGroup t WHERE t.idGroup = :idGroup"),
    @NamedQuery(name = "TbGroup.findByGroupName", query = "SELECT t FROM TbGroup t WHERE t.groupName = :groupName"),
    @NamedQuery(name = "TbGroup.findByGroupDesc", query = "SELECT t FROM TbGroup t WHERE t.groupDesc = :groupDesc"),
    @NamedQuery(name = "TbGroup.findByGroupType", query = "SELECT t FROM TbGroup t WHERE t.groupType = :groupType"),
    @NamedQuery(name = "TbGroup.findByCreatedTime", query = "SELECT t FROM TbGroup t WHERE t.createdTime = :createdTime"),
    @NamedQuery(name = "TbGroup.findByCreatedUser", query = "SELECT t FROM TbGroup t WHERE t.createdUser = :createdUser"),
    @NamedQuery(name = "TbGroup.findBySign", query = "SELECT t FROM TbGroup t WHERE t.sign = :sign")})
public class TbGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_GROUP")
    private String idGroup;
    @Column(name = "GROUP_NAME")
    private String groupName;
    @Column(name = "GROUP_DESC")
    private String groupDesc;
    @Column(name = "GROUP_TYPE")
    private String groupType;
    @Column(name = "CREATED_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdTime;
    @Column(name = "CREATED_USER")
    private String createdUser;
    @Column(name = "SIGN")
    private String sign;
    @JoinTable(name = "tb_grou_role", joinColumns = {
        @JoinColumn(name = "ID_GROUP", referencedColumnName = "ID_GROUP")}, inverseJoinColumns = {
        @JoinColumn(name = "ID_ROLE", referencedColumnName = "ID_ROLE")})
    @ManyToMany(fetch=FetchType.EAGER)
    private Set<TbRole> tbRoleSet;
    @ManyToMany(mappedBy = "tbGroupSet",fetch=FetchType.LAZY)
    private Set<TbUser> tbUserSet;

    public TbGroup() {
    }

    public TbGroup(String idGroup) {
        this.idGroup = idGroup;
    }

    public String getIdGroup() {
        return idGroup;
    }

    public void setIdGroup(String idGroup) {
        this.idGroup = idGroup;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getGroupDesc() {
        return groupDesc;
    }

    public void setGroupDesc(String groupDesc) {
        this.groupDesc = groupDesc;
    }

    public String getGroupType() {
        return groupType;
    }

    public void setGroupType(String groupType) {
        this.groupType = groupType;
    }

    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public String getCreatedUser() {
        return createdUser;
    }

    public void setCreatedUser(String createdUser) {
        this.createdUser = createdUser;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public Set<TbRole> getTbRoleSet() {
        return tbRoleSet;
    }

    public void setTbRoleSet(Set<TbRole> tbRoleSet) {
        this.tbRoleSet = tbRoleSet;
    }

    public Set<TbUser> getTbUserSet() {
        return tbUserSet;
    }

    public void setTbUserSet(Set<TbUser> tbUserSet) {
        this.tbUserSet = tbUserSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idGroup != null ? idGroup.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbGroup)) {
            return false;
        }
        TbGroup other = (TbGroup) object;
        if ((this.idGroup == null && other.idGroup != null) || (this.idGroup != null && !this.idGroup.equals(other.idGroup))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.site.user.pojo.TbGroup[idGroup=" + idGroup + "]";
    }

}
